package com.liuqi.business.enums;

import com.liuqi.business.dto.SelectDto;

import java.util.ArrayList;
import java.util.List;

public enum WalletLogTypeEnum {
    SYS("系统", 1,true),
    TRANSFER("转账", 2,false),
    RECHARGE("充值", 3,true),
    EXTRACT("提现", 4,true),
    CONTRACT("合约",5,true),
    GRADE("等级",6,true);




    private String name;
    private Integer code;
    private boolean using;//是否使用

    WalletLogTypeEnum(String name, Integer code,boolean using) {
        this.name = name;
        this.code = code;
        this.using = using;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static String getName(Integer code) {
        for (WalletLogTypeEnum e : WalletLogTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e.getName();
            }
        }
        return "";
    }

    public static List<SelectDto> getList() {
        List<SelectDto> list = new ArrayList<SelectDto>();
        for (WalletLogTypeEnum e : WalletLogTypeEnum.values()) {
            if(e.using) {
                list.add(new SelectDto(e.getCode(), e.getName()));
            }
        }
        return list;
    }
}
